# -*- coding:utf-8 -*-
from Crypto.Cipher import AES
from binascii import a2b_hex


## AesCrypto
class AesCrypto():
    'A class of AesCrypto'

    def __init__(self):
        self.key = 'w28Cz694s63kBYk4'.encode('utf-8')
        self.iv = b'4kYBk36s496zC82w'

    # 解密后，去掉补足的空格
    def decrypt(self, text):
        mode = AES.MODE_CBC
        cryptos = AES.new(self.key, mode, self.iv)
        plain_text = cryptos.decrypt(a2b_hex(text))
        return bytes.decode(plain_text).rstrip("\x01"). \
            rstrip("\x02").rstrip("\x03").rstrip("\x04").rstrip("\x05"). \
            rstrip("\x06").rstrip("\x07").rstrip("\x08").rstrip("\x09"). \
            rstrip("\x0a").rstrip("\x0b").rstrip("\x0c").rstrip("\x0d"). \
            rstrip("\x0e").rstrip("\x0f").rstrip("\x10")


if __name__ == '__main__':
    aes = AesCrypto()
    data = ""
    content = aes.decrypt(data)
    print(content)
